<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>

<c:set var="ctx" value="${pageContext.request.contextPath}" />

<c:set var="queryList"
	value="${pageContext.request.contextPath}/unit/list" />


	<div class="iframe-cot pull-right" id="smIframe" style="background:#FFFFFF;">
		<div class="right-form">
			<form id="_query_form" action="" class="form-inline" onsubmit="return false;">
			<div class="tb_search">
            <div class="pull-left">
            	<span class="search-more">更多条件<i class="fa fa-angle-down ml5"></i></span>	
				<div class="form-group-Wdate">
					<label for="unitName">机构名：</label> 
					<input type="text" name="unitName" value="${unitName }" />
				</div>

				<div class="form-group">
					<label for="unitNO">编码：</label>
					<input type="text" name="unitNO" value="${unitNO }" />
				</div>
				
				<div class="form-group-Wdate">
				<label for="postName">类型：</label>
					<select value="${unitType}" name="unitType" style="">
					
						<option value=""
							<c:if test="${ empty unitType }">selected='selected'</c:if>>请选择</option>
						<option value="1"
							<c:if test="${ '1' eq unitType }">selected='selected'</c:if>>部门</option>
						<option value="0"
							<c:if test="${ '0' eq unitType }">selected='selected'</c:if>>单位</option>
					</select>
				</div>
				
				<%-- <div class="form-group">
					<label for="postName">状态：</label>
					<select value="${status}" name="status" class="form-control-select" style="">
						<option value="" <c:if test="${ empty status }">selected='selected'</c:if>>请选择</option>
						<option value="1"
							<c:if test="${ '1' eq status }">selected='selected'</c:if>>启用</option>
						<option value="0"
							<c:if test="${ '0' eq status }">selected='selected'</c:if>>停用</option>
					</select>
				</div> --%>
				
				<div class="form-group">
					<label for="postName">上级机构：</label>
					<input id="s_unitName" name="pUnitName" class="inputText_sm"
						value="${pUnitName}" type="text" readonly placeHolder='请选择'/> 
					<input id="s_unitId" name="unitId" type="hidden" value="${unitId}" />
				</div>
				
			</div>
			</div>
			</form>
		</div>
		
		<div class="line-e6e"></div>
		
		<div class="form-top">
             <div class="pull-left">
                 <%--  <button class="btn btn-default" onclick="goAdd('${ctx}/unit/goEdit','新增机构')"><i class="fa fa-plus mr5"></i>新增</button>
                 <button class="btn btn-default" onclick="goUpdateUnit('${ctx}/unit/goEdit?currentPage=${pageBean.currentPage}&pageSize=${pageBean.pageSize }','修改机构信息')"><i class="fa fa-pencil mr5"></i>编辑</button>
             
            	 <button class="btn btn-default" onclick="enable()"><i class="fa fa-check-circle-o mr5"></i>启用</button>
             	<button class="btn btn-default" onclick="ban()"><i class="fa fa-ban mr5"></i>停用</button>
             --%>
             </div>
             <div class="pull-right">
               <shiro:hasPermission name="common-service-unit:query">
                 <a class="btn btn-orange" onclick="changePage('${queryList }/table','#_query_form','1','${pageBean.pageSize }',0,true)"><i class="fa fa-search mr5"></i>查询</a>
                 <a class="btn btn-blue" onclick="cleanForm()"><i class="fa fa-trash-o mr5"></i>清空</a>
               </shiro:hasPermission>
             </div>
         </div>
		<div id="table-papination">
		
		</div>
	</div>

	<!--main end-->
	
	<!-- 放到index.jsp后面了，这个div的父级必须是body -->
<!-- <div id="treediv" style='top:75px;left:50px;overflow:scroll;display:none; position:absolute;width:300px;height:200px;background-color:#eeffdd; border:1px solid #BEC0BF;padding:5px;font-size:12px;'>
	<a onclick="hidetreediv();" href="#" class="link-red mr5" style="cursor:pointer;color:red;text-align:right;"><i class="fa fa-close"></i>取消</a>
	<ul id="tree" class="ztree"></ul>
</div> -->

	 <script src="${ctx}/static/js/search-more.js"></script> <!--更多查询条件-->
	<script src="${ctx}/static/js/jquery.ztree.all-3.5.js"></script>
	
<script type="text/javascript">

currentPageNo = parseInt('${pageBean.currentPage}');
currentPageSize = parseInt('${pageBean.pageSize }');
totalPageCount = parseInt('${pageBean.totalPage}');
queryUrl = '${ctx}/unit/list';

	$(document).ready(function() {

		$("#s_unitName").focus(function() {
			var divObj = $("#treediv");
        //	var txtObj = $("#s_unitName");
        	showDiv(divObj,this,unitsetting,"${ctx}/user/getUnit");
		});
		//加载表格内容
		 loadConent('${queryList }/table','',true);

	});
	
	function cleanForm(){
		$("#s_unitId").val('');
		clearForm('#_query_form');
	}
	
	//启用
	function enable(){
		
		deleteById('请确认是否启用',1);
	}
	//停用
	function ban(){
		deleteById('请确认是否停用',0);
	}
	
	function deleteById(msg,status) {
		var ids = getListTableCheckboxValue() ;
		 if( ids == ''){
			 warnTip('请选择一条记录');
			 return;
		 }
		 
		 layer.confirm(msg, {
		 	    btn: ['确定', '取消']
		 	    ,yes: function(index){
		 	    	$.post("${ctx}/unit/deleteByIds",{'ids':ids,'status':status},function(result){
		 	  		if(result.code=="success"){
		 	  			 successTip();
		 	  			//刷新列表
		 	  			jumpPage();
		 	  		}else{
		 	  		errorTip();
		 	  		}
		 	  	},"json");
		 	    }
		 	});
		 
	}
	
	function goUpdateUnit(_url, _title) {
		var isCheckOne = isCheckOneWhenEdit();
		 if( !isCheckOne){
			 return;
		 }
		
		layer.open({
			type : 2,
			title : _title,
			maxmin : false,
			shadeClose : false, //点击遮罩关闭层
			area : [ '800px', '550px' ],
			content : _url + "&unitId=" + $("input[name='checkboxOne']:checked").val()
		});
	}
</script>